# -*- coding:utf8 -*-
# 崔烁豪
# 时间：2021-05-17 15:35
# https://aistudio.baidu.com/aistudio/projectdetail/1243085

import paddle
import numpy as np
from PIL import Image

import matplotlib.pyplot as plt

train_dataset = paddle.vision.datasets.MNIST(mode='train')
test_dataset = paddle.vision.datasets.MNIST(mode='test')
# 取其中的一条数据看一下，如图所示：


train_data0, train_label_0 = train_dataset[0][0], train_dataset[0][1]
# print(type(train_data0))

# 将RGB转化为灰度图像，像素值在0~255之间
train_data0=Image.open('1.png').convert('L')
#resize image with high-quality
train_data0 = train_data0.resize((28, 28), Image.ANTIALIAS)

# print(type(train_data0))
train_data0 = np.array(train_data0).reshape([28, 28])

print(type(train_data0))
# print(str(train_data0))
# %matplotlib inline


plt.figure(figsize=(2, 2))
plt.imshow(train_data0, cmap=plt.cm.binary)
print('train_data0 label is: ' + str(train_label_0))

plt.show()